package top.dark.order;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import java.util.concurrent.TimeUnit;

@EnableFeignClients(basePackages = "top.dark.order.feign")
@EnableDiscoveryClient
@SpringBootApplication
public class MallOrderApplication {

    public static void main(String[] args) {
        // SpringApplication.run(MallOrderApplication.class, args);
        // 检验nacos配置中心是否配好
        ConfigurableApplicationContext applicationContext = SpringApplication.run(MallOrderApplication.class, args);
        while(true) {
            //当动态配置刷新时，会更新到 Enviroment中，因此这里每隔一秒中从Enviroment中获取配置
            String userName = applicationContext.getEnvironment().getProperty("value");
            System.err.println("value name :" + userName);
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
